cmake_minimum_required(VERSION 2.8.3)
project(moying_proto_test)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  moying_proto
  moying_comm_lib
)
find_package(Protobuf REQUIRED)
find_package(PkgConfig)
find_package(log4cplus)

if(NOT DEFINED $log4cplus_LIBRARIES)
  set( log4cplus_LIBRARIES "/usr/local/lib/liblog4cplus.so")
endif()

MESSAGE( STATUS "log4cplus_LIBRARIES: ${log4cplus_LIBRARIES}")

#pkg_check_modules(log4cplus REQUIRED log4cplus>=2.0.0)
catkin_package(
  INCLUDE_DIRS include 
  LIBRARIES moying_proto_test
  CATKIN_DEPENDS moying_proto moying_comm_lib
)

include_directories(
  include 
  ${catkin_INCLUDE_DIRS}
) 

add_executable(pub src/pub.cpp) 
add_dependencies(pub ${catkin_EXPORTED_TARGETS})
target_link_libraries(pub
  ${catkin_LIBRARIES}
  ${Protobuf_LIBRARIES}
  #${log4cplus_LIBRARY_DIRS}/liblog4cplus.so
  ${log4cplus_LIBRARIES}
)

add_executable(sub src/sub.cpp)
add_dependencies(sub ${catkin_EXPORTED_TARGETS})
target_link_libraries(sub 
  ${catkin_LIBRARIES}
  ${Protobuf_LIBRARIES}
  #${log4cplus_LIBRARY_DIRS}/liblog4cplus.so
  ${log4cplus_LIBRARIES}
)

add_executable(req src/req.cpp)
add_dependencies(req ${catkin_EXPORTED_TARGETS})
target_link_libraries(req
  ${catkin_LIBRARIES}
  ${Protobuf_LIBRARIES}
  #${log4cplus_LIBRARY_DIRS}/liblog4cplus.so
  ${log4cplus_LIBRARIES}
)

add_executable(rep src/rep.cpp)
add_dependencies(rep ${catkin_EXPORTED_TARGETS})
target_link_libraries(rep
  ${catkin_LIBRARIES}
  ${Protobuf_LIBRARIES}
  #${log4cplus_LIBRARY_DIRS}/liblog4cplus.so
  ${log4cplus_LIBRARIES}
)